package com.sxz.sbs.module.client.presenter;

import com.sxz.sbs.app.App;
import com.sxz.sbs.module.client.bean.ClientBasicBean;
import com.sxz.sbs.module.client.view.ClientBasicView;
import com.sxz.sbs.rx.RxPresenter;
import com.sxz.sbs.rx.RxSubscriber;
import com.sxz.sbs.rx.RxUtil;

import java.util.HashMap;

/**
 * 新增业主
 */
public class ClientBasicPresenter extends RxPresenter<ClientBasicView>{
    /**
     * @param map
     *  修改客户信息
     */
    public void getAmendClient (final HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().getAddClient(map)
                .compose(RxUtil.<String>handleResult())
                .subscribeWith(new RxSubscriber<String>(mView,true){
                    @Override
                    public void onNext(String data) {
                        mView.onClientAmendSuccess(data);
                    }
                })
        );
    }

    /**
     * @param map
     *  获取基本信息
     */
    public void getClientBasic (final HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().getEssentialInformation(map)
                .compose(RxUtil.<ClientBasicBean>handleResult())
                .subscribeWith(new RxSubscriber<ClientBasicBean>(mView,true){
                    @Override
                    public void onNext(ClientBasicBean data) {
                        mView.onEssentialInformationSuccess(data);
                    }
                })
        );
    }
}
